﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Common
{
    public sealed class SerialInfoHelper
    {
        public class SerialInfo
        {
            public int CsId { set; get; }

            public string CsName { get; set; }

            public string CsShowName { set; get; }

            public string ReferPrice { set; get; }

            public string EE { set; get; }

            public string TT { set; get; }
        }

        private SerialInfoHelper() { ;}

        private const string _serialInfoUrl = @"http://car.bitauto.com/car/interfaceforbitauto/Serial/AllSerialInfo.aspx?dept=bitautocheyisou";

        private static string _allSerialInfo = WebUtils.GetData(_serialInfoUrl);

       // private static XElement allSerialInfoXml = XElement.Parse(_allSerialInfo.Trim(), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo);

        //public static SerialInfo GetSerialInfo(int serialId)
        //{
        //    var element = from node in allSerialInfoXml.Descendants("Cs")
        //                  where node.Attribute("ID").Value == serialId.ToString()
        //                  select new SerialInfo
        //                  {
        //                      CsId = serialId,
        //                      CsName = node.Attribute("CsName").Value,
        //                      CsShowName = node.Attribute("CsShowName").Value,
        //                      ReferPrice = node.Attribute("ReferPrice").Value,
        //                      EE = node.Attribute("EE").Value,
        //                      TT = node.Attribute("TT").Value
        //                  };

        //    try { return (element != null) ? element.ElementAt(0) : null; }
        //    catch { return null; }
        //}
    }
}
